# Stage 1
FROM node:8 as react-build
WORKDIR /app
COPY . /app
RUN npm config set registry https://mirrors.huaweicloud.com/repository/npm/
RUN npm config set disturl https://mirrors.huaweicloud.com/nodejs/
RUN yarn config set registry https://mirrors.huaweicloud.com/repository/npm/
RUN npm config set sass_binary_site https://repo.huaweicloud.com/node-sass/
RUN yarn config set sass_binary_site https://repo.huaweicloud.com/node-sass/
RUN yarn
RUN yarn build:dev

# Stage 2 - the production environment
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=react-build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]